package com.wzq.design.tools;

import com.wzq.ssm.parent.redis.SpringRedisClient;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2017-09-29.
 */
@Component
public class StartupListener implements ApplicationListener<ContextRefreshedEvent> {
    @Resource
    private SpringRedisClient springRedisClient;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        if (contextRefreshedEvent.getApplicationContext().getDisplayName().equals("Root WebApplicationContext")) {//root application context 没有parent，他就是老大.
            //---------------------------初始化开始------------------------------
            //1:清楚redis的缓存
            springRedisClient.clear();
        }
    }
}
